/**
 * @description 移动端JS
 * @author 赵子靖
 * @since 2017-12-12
 */
var Mobile = function() {
    var t = {
        path :'',
        init : function(path) {
            t.path = path;
            t.initView();
            t.initEvent();
        },
        initView : function() {
            
        },
        initEvent : function() {
            
        },
        //分类列表
        forwardShopType:function(){
            layer.open({
                type: 2
                ,content: '加载中'
            });
            //模糊搜索
            var search = $("#search").val();
            //商品类别
            var shopType = '';
            $('#shopType').find('li').each(function() {
                if("list-curr"==$(this).attr("class")){
                    shopType = $(this).attr("id");    
                }
            })
            //排序
            var sortType = "";
            var sort = ''; //排序
            $("#shopSort").find("li").each(function(){
                if("tip-red"==$(this).attr("class")){
                    //查找到需要排序的标签
                    sortType = $(this).attr("id");
                    if("fa fa-sort-down"==$(this).find("i").attr("class")){
                        sort = 'desc';
                    }else{
                        sort = 'asc';
                    }
                }
            });
            window.location.href=t.path+"/mobile/forwardShopType.do?search="+search+"&shopType="+shopType+"&sortType="+sortType+"&sort="+sort;
        },
        //分类选择
        shopTypeClick:function(shopType){
            $('#shopType').find('li').each(function() {
                $(this).removeClass();
            })
            $("#"+shopType).attr("class","list-curr");
            t.forwardShopType();
        },
        initShopType:function(shopType){
            $('#shopType').find('li').each(function() {
                $(this).removeClass();
            })
            $("#"+shopType).attr("class","list-curr");
        },
        //初始化排序
        initShopSort:function(shopPriceSort,shopSellSort){
            if("desc"==shopPriceSort){
                $("#shopPrice").attr("class","list-menu-arrow-down");
            }else{
                $("#shopPrice").attr("class","list-menu-arrow-up");
            }
            if("asc"==shopSellSort){
                $("#shopSell").attr("class","list-menu-arrow-up");
            }else{
                $("#shopSell").attr("class","list-menu-arrow-down");
            }
        },
        //排序
        shopSort:function($this,sortType){
            var sort = '';  //排序类型 desc或者asc
            var clazz = $($this).find('i').attr("class");
            if("fa fa-sort-down"==clazz){
                $($this).find('i').attr("class","fa fa-sort-up");
                sort = 'asc';
            }else if("fa fa-sort-up"==clazz){
                $($this).find('i').attr("class","fa fa-sort-down");
                sort = 'desc';
            }
            $("#shopSort").find("li").each(function(){
                $(this).removeClass();
            });
            $($this).attr("class","tip-red");
            t.forwardShopType();
        }
    }
    return t;
}();